package day07home;
/*
需求：
  机票价格按照淡季旺季、头等舱、商务舱和经济舱收费，
  输入机票原价、月份和头等舱、商务舱或经济舱，
  其中旺季（5-10月）头等舱9折，商务舱85折，经济舱8折，
  淡季（11月到来年4月）头等舱7折，商务舱65折，经济舱6折，
  最终输出机票价格
 */
import java.util.Scanner;

public class AirPriceDemo {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入机票的价格");
        double price=scan.nextDouble();
        System.out.println("请输入月份：");
        int month=scan.nextInt();
        System.out.println("请选择1、头等舱，2、商务舱，3、经济舱");
        int type=scan.nextInt();
        double calaairprice=airprice(price,month,type);
        if(calaairprice!=1){
            System.out.println("机票价格为："+calaairprice);
        }
    }
    public static double airprice(double price,int month,int type){
        double airprice=0.0;
        if(month<1||month>12){
            System.out.println("输入错误");
            return -1;
        }
        if(type<1||type>3){
            System.out.println("输入错误");
            return -1;
        }
        if(month>=5&&month<=10){
            switch (type){
                case 1:
                    airprice=price*0.9;
                    break;
                case 2:
                    airprice=price*0.85;
                    break;
                case 3:
                    airprice=price*0.8;
                    break;
            }

        }else {
            switch (type){
                case 1:
                    airprice=price*0.7;
                    break;
                case 2:
                    airprice=price*0.65;
                    break;
                case 3:
                    airprice=price*0.6;
                    break;
            }
        }
        return airprice;
    }


}
